﻿using System;
using System.Collections.Generic;
using System.Web;
using Utils;

/// <summary>
///FBasePage 的摘要说明
/// </summary>
public class FBasePage : BasePage
{
    // Methods
    private void getFromdomain(string str)
    {
        string str2 = "";
        if (str != null)
        {
            str2 = str.Split(new char[] { '/' })[2];
        }
        CookieHelper.SetCookie("fromdomain", Helper.GetString(str2, "直接输入网址"));
    }

    protected bool isselectcity()
    {
        string str = Helper.GetString(base.Request["ename"], string.Empty);
        if (str != string.Empty)
        {
            List< Maticsoft.Model.Category> modelList = new Maticsoft.BLL.Category().GetModelList("Zone='city' and ename='" + str + "'");
            if (modelList.Count > 0)
            {
                CookieHelper.SetCookie("cityid", modelList[0].Id.ToString(), DateTime.Now.AddYears(1));
                return true;
            }
        }
        return false;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        base.IncludeEditorJS();
        if ((base.Request["r"] != null) && (this.Session["invitor"] == null))
        {
            int @int = Helper.GetInt(base.Request["r"], 0);
            if (@int > 0)
            {
                Maticsoft.Model.UserInfo model = null;
                model = new Maticsoft.BLL.UserInfo().GetModel(@int);
                if (model != null)
                {
                    this.Session["invitor"] = model.Id;
                }
            }
        }
        if (CookieHelper.GetCookieValue("gourl").Length == 0)
        {
            string absoluteUri = base.Request.Url.AbsoluteUri;
            CookieHelper.SetCookie("gourl", Helper.GetString(base.Request.ServerVariables["HTTP_REFERER"], "直接输入网址"));
        }
        bool flag = false;
        string url = string.Empty;
        if (this.isselectcity())
        {
            url = base.Request.Url.AbsoluteUri.Replace("ename=", "n=");
            if (url.IndexOf("city.aspx") >= 0)
            {
                url = "~/index.aspx";
            }
        }
        flag = base.IsUse();
        if (url.Length > 0)
        {
            base.Response.Redirect(url);
            base.Response.End();
        }
        else if (flag)
        {
            base.Response.Redirect(base.Request.Url.AbsoluteUri);
            base.Response.End();
        }
    }
}

 
